package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Zhuanjiabiao;
import com.ruoyi.system.service.IZhuanjiabiaoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专家管理Controller
 *
 * @author ruoyi
 * @date 2023-11-22
 */
@RestController
@RequestMapping("/system/zhuanjiabiao")
@Api(tags = "专家相关接口")
public class ZhuanjiabiaoController extends BaseController
{
    @Autowired
    private IZhuanjiabiaoService zhuanjiabiaoService;

  /**
   * 获取部门树列表
   */
//    @PreAuthorize("@ss.hasPermi('system:zhuanjiabiao:unit')")
  @GetMapping("/unit")
  @ApiOperation("获取推荐单位")
  public AjaxResult deptTree()
  {
    return success(zhuanjiabiaoService.selectUnitList());
  }

    /**
     * 查询专家管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:zhuanjiabiao:list')")
    @GetMapping("/list")
    @ApiOperation("查询专家列表")
    public TableDataInfo list(Zhuanjiabiao zhuanjiabiao)
    {
        startPage();
        List<Zhuanjiabiao> list = zhuanjiabiaoService.selectZhuanjiabiaoList(zhuanjiabiao);
        for(Zhuanjiabiao zj :list){
//           zj.setXl(map.find(zj.getXl()));
        }
        return getDataTable(list);
    }

    /**
     * 导出专家管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:zhuanjiabiao:export')")
    @Log(title = "专家管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Zhuanjiabiao zhuanjiabiao)
    {
        List<Zhuanjiabiao> list = zhuanjiabiaoService.selectZhuanjiabiaoList(zhuanjiabiao);
        ExcelUtil<Zhuanjiabiao> util = new ExcelUtil<Zhuanjiabiao>(Zhuanjiabiao.class);
        util.exportExcel(response, list, "专家管理数据");
    }

    /**
     * 获取专家管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:zhuanjiabiao:query')")
    @GetMapping(value = "/{zjId}")
    @ApiOperation("获取专家详细信息")
    public AjaxResult getInfo(@PathVariable("zjId") Long zjId)
    {
        return success(zhuanjiabiaoService.selectZhuanjiabiaoByZjId(zjId));
    }

    /**
     * 新增专家管理
     */
    @PreAuthorize("@ss.hasPermi('system:zhuanjiabiao:add')")
    @Log(title = "专家管理", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增专家管理")
    public AjaxResult add(@RequestBody Zhuanjiabiao zhuanjiabiao)
    {
        return toAjax(zhuanjiabiaoService.insertZhuanjiabiao(zhuanjiabiao));
    }

    /**
     * 修改专家管理
     */
    @PreAuthorize("@ss.hasPermi('system:zhuanjiabiao:edit')")
    @Log(title = "专家管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改专家管理")
    public AjaxResult edit(@RequestBody Zhuanjiabiao zhuanjiabiao)
    {
        return toAjax(zhuanjiabiaoService.updateZhuanjiabiao(zhuanjiabiao));
    }

    /**
     * 删除专家管理
     */
    @PreAuthorize("@ss.hasPermi('system:zhuanjiabiao:remove')")
    @Log(title = "专家管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{zjIds}")
    @ApiOperation("删除专家管理")
    public AjaxResult remove(@PathVariable Long[] zjIds)
    {
        return toAjax(zhuanjiabiaoService.deleteZhuanjiabiaoByZjIds(zjIds));
    }
}
